package edu.ctbu.hello.controller;


import edu.ctbu.hello.domain.Student;
import edu.ctbu.hello.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HelloController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/hello")
    public String SayHi() {
        return "Hello SpringBoot!";
    }


    @RequestMapping("/hi")
    public String TestTwo() {
        return "这是中文";
    }


    @RequestMapping("/student/getall")
    public List<Student> GetAll() {

        return studentService.findAll();

    }

    @RequestMapping("/student/findbyname")
    public List<Student> findByName(String name) {
        return studentService.findByName(name);
    }

    @RequestMapping("/student/delete")
    public void deleteById(Integer id) {
        studentService.deleteById(id);
    }


}
